<template>
  <div class="home">
    <el-container>
      <el-header>
        <h1>数字化管理平台</h1>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
              default-active="1"
              class="el-menu-vertical-demo"
              active-text-color="#ffd04b"
              background-color="#545c64"
              text-color="#fff"
          >
            <el-menu-item index="1" @click="handleOpen">
              <span>客户信息</span>
            </el-menu-item>
            <el-menu-item index="2" @click="handleOpen">
              <span>机器管理</span>
            </el-menu-item>
            <el-menu-item index="3" @click="handleOpen">
              <span>关于</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
      <el-footer>Inc</el-footer>
    </el-container>
  </div>
</template>

<script>
// @ is an alias to /src

export default {
  name: 'Home',
  components: {

  },
  data() {
    return {
      menus: [
        {
          index: 1,
          name: "Customer",
        },
        {
          index: 2,
          name: "Printer",
        },
        {
          index: 3,
          name: "About",
        },
      ],
    };
  },
  mounted() {
    // this.sidebarItem = this.$route.name;
  },
  methods: {
    handleOpen(data) {
      console.log(this.menus[data.index - 1].name);
      this.sidebarItem = this.menus[data.index - 1].name;
      this.$router.push({
        name: this.menus[data.index - 1].name,
      });
    },
  },
}
</script>
